package com.fengze.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fengze.common.annotation.Log;
import com.fengze.common.core.controller.BaseController;
import com.fengze.common.core.domain.AjaxResult;
import com.fengze.common.enums.BusinessType;
import com.fengze.business.domain.ReimbursementList;
import com.fengze.business.service.IReimbursementListService;
import com.fengze.common.utils.poi.ExcelUtil;
import com.fengze.common.core.page.TableDataInfo;

/**
 * 报销清单Controller
 * 
 * @author lug
 * @date 2024-02-28
 */
@RestController
@RequestMapping("/reimbursement/list")
public class ReimbursementListController extends BaseController
{
    @Autowired
    private IReimbursementListService reimbursementListService;

    /**
     * 查询报销清单列表
     */
    @PreAuthorize("@ss.hasPermi('reimbursement:list:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReimbursementList reimbursementList)
    {
        startPage();
        List<ReimbursementList> list = reimbursementListService.selectReimbursementListList(reimbursementList);
        return getDataTable(list);
    }

    /**
     * 导出报销清单列表
     */
    @PreAuthorize("@ss.hasPermi('reimbursement:list:export')")
    @Log(title = "报销清单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReimbursementList reimbursementList)
    {
        List<ReimbursementList> list = reimbursementListService.selectReimbursementListList(reimbursementList);
        ExcelUtil<ReimbursementList> util = new ExcelUtil<ReimbursementList>(ReimbursementList.class);
        util.exportExcel(response, list, "报销清单数据");
    }

    /**
     * 获取报销清单详细信息
     */
    @PreAuthorize("@ss.hasPermi('reimbursement:list:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(reimbursementListService.selectReimbursementListById(id));
    }

    /**
     * 新增报销清单
     */
    @PreAuthorize("@ss.hasPermi('reimbursement:list:add')")
    @Log(title = "报销清单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReimbursementList reimbursementList)
    {
        return toAjax(reimbursementListService.insertReimbursementList(reimbursementList));
    }

    /**
     * 修改报销清单
     */
    @PreAuthorize("@ss.hasPermi('reimbursement:list:edit')")
    @Log(title = "报销清单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReimbursementList reimbursementList)
    {
        return toAjax(reimbursementListService.updateReimbursementList(reimbursementList));
    }

    /**
     * 删除报销清单
     */
    @PreAuthorize("@ss.hasPermi('reimbursement:list:remove')")
    @Log(title = "报销清单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(reimbursementListService.deleteReimbursementListById(id));
    }
}
